]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
messageTray: Don't always open the source when clicking on the notification
authorJasper St. Pierre <jstpierre@mecheye.net>
Mon, 14 Oct 2013 03:20:50 +0000 (23:20 -0400)
committerJasper St. Pierre <jstpierre@mecheye.net>
Mon, 21 Oct 2013 16:30:25 +0000 (12:30 -0400)
Some consumers may not always want to open the app, so make clients that
want to do this explicitly connect to the 'clicked' signal.

https://bugzilla.gnome.org/show_bug.cgi?id=710137

js/ui/components/telepathyClient.js
js/ui/messageTray.js
js/ui/notificationDaemon.js
js/ui/windowAttentionHandler.js

index 739bb9064f8d7010a599bc2435d42c88e80a3177..c4565ecff949f96de3e968371e40568800aef6b8 100644 (file)
@@ -446,6 +446,7 @@ const ChatSource = new Lang.Class({
         this._closedId = this._channel.connect('invalidated', Lang.bind(this, this._channelClosed));
 
         this._notification = new ChatNotification(this);
+        this._notification.connect('clicked', Lang.bind(this, this.open));
         this._notification.setUrgency(MessageTray.Urgency.HIGH);
         this._notifyTimeoutId = 0;
 
@@ -544,20 +545,19 @@ const ChatSource = new Lang.Class({
         this._notification.update(this._notification.title, null, { customContent: true });
     },
 
-    open: function(notification) {
-          if (this._client.is_handling_channel(this._channel)) {
-              // We are handling the channel, try to pass it to Empathy
-              this._client.delegate_channels_async([this._channel],
-                  global.get_current_time(),
-                  'org.freedesktop.Telepathy.Client.Empathy.Chat', null);
-          }
-          else {
-              // We are not the handler, just ask to present the channel
-              let dbus = Tp.DBusDaemon.dup();
-              let cd = Tp.ChannelDispatcher.new(dbus);
-
-              cd.present_channel_async(this._channel, global.get_current_time(), null);
-          }
+    open: function() {
+        if (this._client.is_handling_channel(this._channel)) {
+            // We are handling the channel, try to pass it to Empathy
+            this._client.delegate_channels_async([this._channel],
+                                                 global.get_current_time(),
+                                                 'org.freedesktop.Telepathy.Client.Empathy.Chat', null);
+        } else {
+            // We are not the handler, just ask to present the channel
+            let dbus = Tp.DBusDaemon.dup();
+            let cd = Tp.ChannelDispatcher.new(dbus);
+
+            cd.present_channel_async(this._channel, global.get_current_time(), null);
+        }
     },
 
     _getLogMessages: function() {
index e7e722e7232941b639d23dc559dd1d9e3e0a96e2..75c3027f2533fa77566fe7e12b268709702c7ab2 100644 (file)
@@ -1385,9 +1385,7 @@ const Source = new Lang.Class({
         if (this.notifications.indexOf(notification) >= 0)
             return;
 
-        notification.connect('clicked', Lang.bind(this, this.open));
         notification.connect('destroy', Lang.bind(this, this._onNotificationDestroy));
-
         this.notifications.push(notification);
         this.emit('notification-added', notification);
 
index c714ff138a7acd5dd7054501f488f2b07fc0d1a7..3e47dc75dc58722d0bf6a19bc3d6c6acb6f68429 100644 (file)
@@ -422,15 +422,15 @@ const NotificationDaemon = new Lang.Class({
                                              soundName: hints['sound-name'] });
         notification.setImage(image);
 
+        let hasDefaultAction = false;
+
         if (actions.length) {
             let useActionIcons = (hints['action-icons'] == true);
 
             for (let i = 0; i < actions.length - 1; i += 2) {
                 let [actionId, label] = [actions[i], actions[i+1]];
                 if (actionId == 'default') {
-                    notification.connect('clicked', Lang.bind(this, function() {
-                        this._emitActionInvoked(ndata.id, "default");
-                    }));
+                    hasDefaultAction = true;
                 } else {
                     notification.addButton(this._makeButton(id, label, useActionIcons), Lang.bind(this, function() {
                         this._emitActionInvoked(ndata.id, actionId);
@@ -438,6 +438,17 @@ const NotificationDaemon = new Lang.Class({
                 }
             }
         }
+
+        if (hasDefaultAction) {
+            notification.connect('clicked', Lang.bind(this, function() {
+                this._emitActionInvoked(ndata.id, 'default');
+            }));
+        } else {
+            notification.connect('clicked', Lang.bind(this, function() {
+                source.open();
+            }));
+        }
+
         switch (hints.urgency) {
             case Urgency.LOW:
                 notification.setUrgency(MessageTray.Urgency.LOW);
index 78e20611e7cbe9c74ab68ff08f670882467c1e41..599eee9a6c0d3c970415f19c53c2412526959fac 100644 (file)
@@ -39,6 +39,9 @@ const WindowAttentionHandler = new Lang.Class({
         let [title, banner] = this._getTitleAndBanner(app, window);
 
         let notification = new MessageTray.Notification(source, title, banner);
+        notification.connect('clicked', function() {
+            source.open();
+        });
         notification.setForFeedback(true);
 
         source.notify(notification);
@@ -79,7 +82,7 @@ const Source = new Lang.Class({
         return this._app.create_icon_texture(size);
     },
 
-    open : function(notification) {
+    open: function() {
         Main.activateWindow(this._window);
         this.destroy();
     }